package com.itheima.service;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.api.CmsSubjectApi;
import com.itheima.pojo.CmsSubject;
import com.itheima.vo.PageResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 袁鹏
 * @date 2022-10-14-8:33
 */
@Service
public class CmsSubjectService {

    @DubboReference
    private CmsSubjectApi cmsSubjectApi;


    /**
     * 根据专题名称分页获取商品专题
     */
    public PageResult<CmsSubject> page(String keyword, Integer pageNum, Integer pageSize) {
        Page<CmsSubject> pageInfo = cmsSubjectApi.page(keyword, pageNum, pageSize);
        return new PageResult<>(Convert.toInt(pageInfo.getCurrent()), Convert.toInt(pageInfo.getSize()), Convert.toInt(pageInfo.getTotal()), Convert.toInt(pageInfo.getCurrent()), pageInfo.getRecords());
    }


    /**
     * 获取全部商品专题
     */
    public List<CmsSubject> listAll() {
        return cmsSubjectApi.listAll();
    }
}
